package crudfx.control;
import javax.swing.*;
import crudfx.interop.*;
import crudfx.data.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class StandardButton extends UIComponent{
    protected var jButton:JButton;
    public var action:function():Void;
    public var icon:javax.swing.Icon on replace{jButton.setIcon(icon);};
    public var text:String="" on replace{jButton.setText(text);};
    //public var tooltip:String="StandardButton" on replace{jButton.setToolTipText(tooltip);};
    init{
        jButton=new JButton();
        jButton.setText(text);
        jButton.setIcon(icon);
        jButton.setVisible(true);
        jButton.addActionListener(ActionListener{
                override function actionPerformed(e:ActionEvent){action();}}
            );
        //jButton.setToolTipText(tooltip);
        }
    override public function getJComponent():JComponent{
        return jButton;
        }
    override public function highlight(s:String):Boolean{
        return false;
        }
    override public function gather():DataTree{
        var me:DataTree=DataTree{ name:"StandardButton" };
        me.node("text").asString("").value=text;
        return me;
        }
    }
